<?xml version="1.0" encoding="utf-8" ?>
<taskrunner name="attach.from.vidasave" version="1.0" date="2008-10-30" maxthreads="1">

  <!-- checks installed version. -->

  <includes>
    <file name="vida.install.settings.xml" />
  </includes>
 
  <tasks>

    <task name="check.vidasave.files" typename="@FileExist">
      <description>
        Check if old databases exists in the VidaSave folder.
      </description>
      
      <errormessage>
        An error occurred while checking whether Microsoft Internet Information Server was running or not.
      </errormessage>
      
      <parameters>
        <parameter name="dir" value="${target.vidasave.dir}"/>
        <parameter name="files" value="${db.accessserver.data.filename},${db.accessserver.log.filename},${db.diagswdlsession.data.filename},${db.diagswdlsession.log.filename}"/>
        <parameter name="output.value" value="vidasave.db.exists"/>
      </parameters>
    </task>

    <task name="move.vidasave.db" condition="¤{vidasave.db.exists}=true" typename="@CopyFiles">
      <dependencies list="check.vidasave.files"/>
      <parameters>
        <parameter name="source.directory" value="${target.vidasave.dir}"/>
        <parameter name="destination.directory" value="${target.db.dir}"/>
        <parameter name="files" value="${db.accessserver.data.filename},${db.accessserver.log.filename},${db.diagswdlsession.data.filename},${db.diagswdlsession.log.filename}"/>
      </parameters>
      
    </task>
    
    <task name="attach.accessserver.from.vidasave" condition="¤{vidasave.db.exists}=true" typename="@SqlServerManagement.AttachDatabase">
      <dependencies list="move.vidasave.db,check.vidasave.files"/>
      <parameters>
        
        <parameter name="server" value="${sqlserver.local.server}"/>
        <parameter name="userid" value="${sqlserver.local.userid}"/>
        <parameter name="password" value="${sqlserver.local.password}"/>
        <parameter name="name" value="${db.accessserver.name}"/>
        <parameter name="datafile" value="${target.db.dir}\${db.accessserver.data.filename}"/>
        <parameter name="logfile" value="${target.db.dir}\${db.accessserver.log.filename}"/>
        <parameter name="detachexisting" value="true"/>
        
      </parameters>
    </task>

    <task name="attach.diagswdlsession.from.vidasave" condition="¤{vidasave.db.exists}=true" typename="@SqlServerManagement.AttachDatabase">
      <dependencies list="attach.accessserver.from.vidasave,check.vidasave.files"/>
      <parameters>
        <parameter name="server" value="${sqlserver.local.server}"/>
        <parameter name="userid" value="${sqlserver.local.userid}"/>
        <parameter name="password" value="${sqlserver.local.password}"/>
        <parameter name="name" value="${db.diagswdlsession.name}"/>
        <parameter name="datafile" value="${target.db.dir}\${db.diagswdlsession.data.filename}"/>
        <parameter name="logfile" value="${target.db.dir}\${db.diagswdlsession.log.filename}"/>
        <parameter name="detachexisting" value="true"/>
      </parameters>
    </task>

    <task name="set.global.property" condition="¤{vidasave.db.exists}=true" typename="@SetGlobalProperty">
      <dependencies list="attach.accessserver.from.vidasave,attach.diagswdlsession.from.vidasave"/>
      <parameters>
        <parameter name="property.name" value="localdb.is.attached"/>
        <parameter name="property.value" value="true"/>
      </parameters>
    </task>

    
  </tasks>
</taskrunner>